struct BrowserCommand<T> {
    name: String,
    payload: T,
}

enum Option<T> {
    Some(T),
    None,
}

enum Result<T, E> {
    Ok(T),
    Err(E),
}

impl<T> BrowserCommand<T> {
    fn new(name: String, payload: T) -> Self {
        Self { name, payload }
    }
    fn get_payload(&self) -> &T {
        &self.payload
    }
}

impl BrowserCommand<String> {
    fn print_payload(&self) {
        println!("navigate to {}", self.payload);
    }
}

fn serialize_payload<T>(value: &T) -> String {
    "placeholder".to_string()
}
fn serialize_payload_string(payload: &String) -> String {
    "placeholder".to_string()
}
fn serialize_payload_i32(payload: &i32) -> String {
    "placeholder".to_string()
}
fn main() {
    // let cmd1 = BrowserCommand {
    //     name: "navigate".to_string(),
    //     payload: "https://www.baidu.com".to_string(),
    // };
    // let cmd2 = BrowserCommand {
    //     name: "search".to_string(),
    //     payload: 200,
    // };
    let cmd1 = BrowserCommand::new("navigate".to_string(), "https://www.baidu.com".to_string());
    let cmd2 = BrowserCommand::new("search".to_string(), 200);
    cmd1.print_payload();
    // cmd2.print_payload();
    let payload1 = cmd1.get_payload();
    let payload2 = cmd2.get_payload();
    let serialized1 = serialize_payload(payload1);
    let serialized2 = serialize_payload(payload2);
    serialize_payload_string(payload1);
    serialize_payload_i32(payload2);
}
